require "EquipHeroScene"
MainScene={}
local NodeID = {ScrollView=11}

MainScene.getNode = function()
  if(MainScene.node) then
    return MainScene.node
  end
  MainScene.node = CCBReader:load("MainSceneHD.ccbi")
  return MainScene.node
end

MainScene.getScene = function()
  if(MainScene.scene) then
    return MainScene.scene
  end
  local sc = CCScene:create()
  sc:addChild(MainScene.getNode())
  print("WarScene.getScene", sc)
  MainScene.scene = sc
  sc:retain()
  return sc  
end

MainScene.enableTouch = function(enable)
  setTouchEnabledAll(MainScene.node, enable)
  local scroll = MainScene.node:getChildByTag(NodeID.ScrollView)
  scroll = TypeCast(scroll, "CCScrollView")
  setTouchEnabledAll(scroll:getContainer(), enable)
end


--建筑点击响应
function onGuanKa()
  MainScene.enableTouch(false)
  local sc = CCDirector:sharedDirector():getRunningScene()
  local guanka = GuanKaScene.getNode()
  sc:addChild(guanka)
  local px,py = guanka:getPosition()
  print("onGuanKa ", px, py)
  local size = CCDirector:sharedDirector():getWinSize()
  guanka:setPosition(0,size.height)
  
  local ac = CCEaseElasticOut:create(CCMoveTo:create(1, ccp(0,0)))
  guanka:runAction(ac)
end

function onJunQi()
  MainScene.enableTouch(false)
  local sc = CCDirector:sharedDirector():getRunningScene()
  local layer = EquipHeroScene.getNode()
  sc:addChild(layer)
  local size = CCDirector:sharedDirector():getWinSize()
  layer:setPosition(0,size.height)
  local ac = CCEaseElasticOut:create(CCMoveTo:create(1, ccp(0,0)))
  layer:runAction(ac)
end


